package com.bytezero.java;


import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;

public class HelloJava {

    public static void main(String[] args) {

        String uid = "001";
        String timestamp = "1635483656733";
        String appKey = "OcR61pUOPNwQkapBzTKkS80t";
        String sign ="Gxa1kmx4XoiSYM6wSjYSuR7y6uoVrSappKeyOcR61pUOPNwQkapBzTKkS80ttimestamp1635483656733uid001Gxa1kmx4XoiSYM6wSjYSuR7y6uoVrS";


        public static String sign(String signContent) throws IOException {
            byte[] bytes = encryptMD5(signContent.getBytes(CHARSET));
            return byte2hex(bytes);
        }

        private static byte[] encryptMD5(byte[] data) throws IOException {
            try {
                MessageDigest md = MessageDigest.getInstance("MD5");
                return md.digest(data);
            } catch (GeneralSecurityException e) {
                throw new IOException(e.toString());
            }
        }

        private static String byte2hex(byte[] bytes) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < bytes.length; ++i) {
                String hex = Integer.toHexString(bytes[i] & 255);
                if (hex.length() == 1) {
                    sb.append("0");
                }sb.append(hex.toUpperCase());
            }return sb.toString();
        }




    }
}





